<?php

/**
 * Alphabet.php
 *
 * Holds class Pagination_Alphabet
 *
 * @package Library
 * @subpackage Pagination
 */

/**
 * Pagination_Alphabet
 *
 * Paginates resultsets alphabetically
 *
 * @package Library
 * @subpackage Pagination
 */
class Pagination_Alphabet {

	/**
	 * Active page
	 * @var string $_active
	 */
	protected $_active = 'A';

	/**
	 * Current page
	 * @var $_current
	 */
	protected $_current = 1;

	/**
	 * Pages
	 * @var array $_page
	 */
	protected $_page;

	/**
	 * Constructor
	 *
	 * @param Mvc_Request $request
	 * @param string $param
	 * @param string $default (optional)
	 * @return void
	 */
	public function __construct(Mvc_Request $request, $param, $default = null) {
		$this->_page = array_merge(range('A', 'Z'), range(0, 9));
		if($default != null)	$default = strtoupper($default);

		// Set active page
		try {
			$this->_active = strtoupper($request->getParam($param));
		}
		catch(Exception $e) {
			$this->_active = Util::ifSet($default, $this->_active);
		}
	}

	/**
	 * Returns active page
	 *
	 * @return string
	 */
	public function getActive() {
		return (string) $this->_active;
	}

	/**
	 * Returns pages
	 *
	 * @return array
	 */
	public function getPages() {
		return $this->_page;
	}

}
